package app.service.sys;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import app.model.sys.SysOrganization;
import base.category.sys.YesOrNo;
import base.dao.HibernateDao;

@Repository
public class SysOrganizationService extends HibernateDao<SysOrganization> {

	public List<Map<String,Object>> queryList() {
		String sql = "select * from Sys_Organization a where a.is_use = " + YesOrNo.YES + " order by a.org_code";
		List<Map<String,Object>> queryListBySql = queryListBySql(sql);
		return queryListBySql;
	}

	public SysOrganization queryEntityById(String id) {
		SysOrganization entity = queryEntityById(id);
		return entity;
	}

	public void delEntity(String ids) {
		if(!StringUtils.isEmpty(ids)){
			String[] idsArray = ids.split(",");
			for (int i = 0; i < idsArray.length; i++) {
				SysOrganization gb = new SysOrganization();
				gb.setId(idsArray[i]);
				del(gb);
			}
		}
	}

	public void saveEntity(SysOrganization sysOrganization) {
		save(sysOrganization);
	}

	public void updateEntity(SysOrganization sysOrganization) {
		mergeAndUpdate(sysOrganization);
	}
}
